/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ocp.bundles.doctors.impl;

import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.BundleActivator;


/**
 *
 * @author paco
 */
public class Activator implements BundleActivator {
    
    public static BundleContext bc = null;

    private static String doctorsNames[] = {
        "Dra. Garcia",
        "Dr. Sanchez",
        "Dr. Lopez"
    };
    private static Doctor doctors[] = null; 


    public void start(BundleContext bc) throws Exception {
        
        System.out.println(bc.getBundle().getHeaders().get(
                        Constants.BUNDLE_NAME)
                        + " comienza...");
        Activator.bc = bc;
        
        doctors = new Doctor[doctorsNames.length];
        for (int i = 0; i < doctors.length ; i++ ){
            doctors[i] = new Doctor( doctorsNames[i] , bc );
            doctors[i].start();
        }
    
    }

    public void stop(BundleContext bc) throws Exception {
        
        System.out.println(bc.getBundle().getHeaders().get(
                        Constants.BUNDLE_NAME)
                        + " termina...");

        for (int i = 0; i < doctors.length; i++) {
            doctors[i].stop();
            doctors[i] = null;
        }
        
        Activator.bc = null;
      
    }
   

}
